
function xxxxx(){
    if(event.keyCode==13)
      {
      if (!confirm("是否确认提交?")) {
					return;
	  }
      var form1=document.getElementById("form1");
	  form1.action="addBillManage.do?method=wuliu2ConfirmBill";	
	  form1.submit();
	  window.close();
	  window.opener.location.href=jsCtx+"/addBillManage.do?method=select";                             
      }
}

function fansile(){
 var ss = document.getElementById("sb");
 ss.focus();
}
function sub(){
   var tal = document.getElementById("for");
   var inputname = tal.getElementsByTagName("input");
   for(var i=0;i<inputname.length;i++){
   if(inputname[i].className!="Wdate"){
   inputname[i].focus();
   inputname[i].blur();
   }
   }
    setTimeout(function(){
   var fan = tal.getElementsByTagName("span");
   var j = 0;
   var ss = "";
   for(var i=0;i<fan.length;i++){
     if(fan[i].innerHTML!=""){
     if(j==0){
     ss = fan[i];
     }
     j ++;
     }
   }
   if(j != 0){
   //alert("请检查输入项目!");
   ss.parentNode.getElementsByTagName("input")[0].focus();   
   return false;
   }
   return true;
   },1000);
}

//2.向select选项中 加入一个Item
function jsAddItemToSelect(objSelect,objItemValue)
{
           var varItem = new Option(objItemValue,objItemValue);
           objSelect.options.add(varItem);
}



function editbill(){
   var form1 = document.getElementById("orderForm");
   var inputname = form1.getElementsByTagName("input");
   for(var i=0;i<inputname.length;i++){
   if(inputname[i].type=="text"){
      inputname[i].focus();
      inputname[i].blur();
   }
   }
   setTimeout(function(){
   var fan = form1.getElementsByTagName("span");
   var j = 0;
   var ss = "";
   for(var i=0;i<fan.length;i++){
     if(fan[i].innerHTML!=""){
     if(j==0){
     ss = fan[i];
     }
     j++;
     }
   }
   if(j != 0){
   ss.parentNode.getElementsByTagName("input")[0].focus();   
   }else{
   var tiid = document.getElementById("tiid");
   tiid.disabled = true;
   var sb1 = document.getElementById("sb1");
   var sb2 = document.getElementById("sb2");
   var ss = document.getElementById("PLList");
   if(ss.rows.length==1){
   alert("缺少产品信息！");
   tiid.disabled = false;
   return;
   }
   var ss1 = document.getElementById("paypoint");
   var ss2 = document.getElementById("paycash");
   var ss3 = document.getElementById("delivercash");
   var ss4 = document.getElementById("allcash");
   var ss5 = document.getElementById("chuang");  
   var ss51 = document.getElementById("orderprice"); 
   var billyubei = document.getElementById("billyubei");
    var va = "";
   var aa = "";
   var dou = ",";
   var fen = ";";
   var gang = "/";
   for(var i=1;i<ss.rows.length;i++){
     var s1 = ss.rows[i].childNodes[0].getElementsByTagName("input")[0];
     var s2 = ss.rows[i].childNodes[0].getElementsByTagName("input")[1]; 
     var s3 = ss.rows[i].childNodes[2].childNodes[0];
     var s4 = ss.rows[i].childNodes[3].childNodes[0]; 
     var s6 = ss.rows[i].childNodes[6].childNodes[0];
     var s7 = ss.rows[i].childNodes[7];
     if(s2.value==""){
     jsAddItemToSelect(sb1,s3.value);
     var s8 = ss.rows[i].childNodes[0].getElementsByTagName("input")[2];
     var s5 = ss.rows[i].childNodes[4].childNodes[2];
     va += s1.value+dou+s4.value+dou+s5.value+dou+s6.value+dou+s7.innerHTML+dou+s8.value+dou;
      if(i!=ss.rows.length-1){
     va = va + fen;
     } 
     }else{
     jsAddItemToSelect(sb2,s3.value);
     var s9 = ss.rows[i].childNodes[5].childNodes[0];
     var s5 = ss.rows[i].childNodes[4].childNodes[0];
     var s10 = ss.rows[i].childNodes[0].getElementsByTagName("input")[2];
     aa += s2.value+dou+s4.value+dou+s5.value+dou+s6.value+dou+s7.innerHTML+dou+s9.value+dou+s10.value+dou;
      if(i!=ss.rows.length-1){
     aa = aa + fen;
     } 
     }    
   }
   ss51.value = ss4.value - ss1.value + ss2.value + ss1.value;
   ss5.value = aa + gang + va + gang + billyubei.value + gang; 
   for(var i=0;i<sb1.options.length;i++){
      sb1.options[i].selected = true; 
   }
   for(var i=0;i<sb2.options.length;i++){
      sb2.options[i].selected = true;
   }
   form1.target = "wuqu";
   form1.submit();
   form1.targer = "";  
   }
 },1000);
}
	
	
		
function dai(a){
var aa = a.value;
var ss = /^[a-zA-Z1-9]+[a-zA-Z0-9]*$/;
var nn =  a.parentNode.getElementsByTagName("span")[0];
if(!(ss.test(aa))&&aa!=""){
   nn.innerHTML = "<br>输入格式不正确";
   }else{
   nn.innerHTML = "";
   } 
}
function jiao(a){
var aa = a.value;
var ss = /^[1-9]\d*$/;
var nn =  a.parentNode.getElementsByTagName("span")[0];
if(!(ss.test(aa))&&aa!=""){
   nn.innerHTML = "<br>请输入数字";
   }else{
   nn.innerHTML = "";
   }  
}
function telephone(a){
var aa = a.value;
var ss = /^(?:13\d|15\d|18\d)-?\d{5}(\d{3}|\*{3})$/;
var nn =  a.parentNode.getElementsByTagName("span")[0];
if(!(ss.test(aa))&&aa!=""){
   nn.innerHTML = "<br>格式不正确";
   }else{
   nn.innerHTML = "";
   }  
}
function phone(a){
var aa = a.value;
var ss = /^(((\d{3,6}-)\d{6,8}(-\d{3,5})?)|(\d{8})?)$/;
var nn =  a.parentNode.getElementsByTagName("span")[0];
if(!(ss.test(aa))&&aa!=""){
   nn.innerHTML = "<br>格式不正确";
   }else{
   nn.innerHTML = "";
   }  
}

function phone1(a){
var aa = a.value;
var ss = /^\d*$/;
var nn =  a.parentNode.getElementsByTagName("span")[0];
if(!(ss.test(aa))&&aa!=""){
   nn.innerHTML = "<br>格式不正确";
   }else{
   nn.innerHTML = "";
   }  
}

function jiao1(a){
var aa = a.value;
var ss = /^[0-9]{6}$/;
var nn =  a.parentNode.getElementsByTagName("span")[0];
if(!(ss.test(aa))&&aa!=""){
   nn.innerHTML = "<br>请输入正确邮编";
   }else{
   nn.innerHTML = "";
   }  
}
function checkdd(bb,b){
var ss = document.getElementsByName("checkbox");
if(b!=3){
var sb = document.getElementById("bu");
}
if(b==3){
var sb1 = document.getElementById("qu1");
}

var ee = 0;
if(bb.checked==true){
bb.checked=true;
}else if(bb.checked==false){
bb.checked=false;
}
for(var i=0;i<ss.length;i++){
   if(ss[i].checked == true){
   ee = 1;
   break;
   } 
   }  
   if(ee==0){
    if(b==3){
   sb1.disabled = true;
   }
   if(b!=3){
      sb.disabled = true;
      }
   }else{
     if(b==3){
   sb1.disabled = false;
   }
   if(b!=3){
      sb.disabled = false;
      }
   }
}

function che(a,b){
var ss = document.getElementsByName("checkbox");
if(b!=3){
var sb = document.getElementById("bu");
}
if(b==3){
var sb1 = document.getElementById("qu1");
}
if(a.checked==true){
  for(var i=0;i<ss.length;i++){
   ss[i].checked = true;
   if(b==3){
   sb1.disabled = false;
   }
   if(b!=3){
   sb.disabled = false;
   }
   }
  }else{
   for(var i=0;i<ss.length;i++){
   ss[i].checked = false;
   if(b!=3){
   sb.disabled = true;
   }
   if(b==3){
   sb1.disabled = true;
   }
   }
  }


}
function count(aa,bb){
   var ta = document.getElementById("PLList");
   //var allcash = document.getElementById("allcash");
   var billyubei = document.getElementById("billyubei");
   billyubei.value = "";
   var kefugao = document.getElementById("kefugao");
   var wuliugao = document.getElementById("wuliugao");
    var wuliu2gao = document.getElementById("wuliu2gao");
   var caiwugao = document.getElementById("caiwugao");
   if(aa==1){
        caiwugao.disabled = true;
        wuliugao.disabled = true;
        wuliu2gao.disabled = true;
   }else if(aa==2){
        wuliugao.disabled = true;
        kefugao.disabled = true;
        wuliu2gao.disabled = true;
   }else if(aa = 3){
        kefugao.disabled = true;
        caiwugao.disabled = true;  
        wuliu2gao.disabled = true; 
   }else{
		kefugao.disabled = true;
        caiwugao.disabled = true;  
        wuliugao.disabled = true; 
   }
   for(i=1;i<ta.rows.length;i++){
      var s = ta.rows[i].childNodes[3].childNodes[0].value;
      var ss = ta.rows[i].childNodes[6].childNodes[0].value;
      ta.rows[i].childNodes[7].innerHTML = s*ss;
      billyubei.value = billyubei.value + ta.rows[i].childNodes[0].getElementsByTagName("input")[1].value +",";
   }
   reCash3();
   allCount=ta.rows.length;
   var ssa = document.getElementById("paypoint");
   if(ssa.value==""){
   ssa.value="0.0";
   }
   if(bb==1){
   alert("订单编辑已经成功!");
   }
}
function overload(a, b) {
	b.value = a.value;
}
function allover() {
	document.getElementById("n1").value = document.getElementById("n2").value;
	document.getElementById("a1").value = document.getElementById("a2").value;
	document.getElementById("p1").value = document.getElementById("p2").value;
	document.getElementById("ph1").value = document.getElementById("ph2").value;
}
function show(url) {
	document.forms[1].method = "post";
	document.forms[1].target = "ppp";
	document.forms[1].action = url;
	document.forms[1].submit();
}
function addPro(id, vip, name, address, postcode, phone, city, point, cash) {
	window.opener.document.getElementById("city").value = city;
	window.opener.document.getElementById("id").value = id;
	window.opener.document.getElementById("v2").value = vip;
	window.opener.document.getElementById("n2").value = name;
	window.opener.document.getElementById("a2").value = address;
	window.opener.document.getElementById("p2").value = postcode;
	window.opener.document.getElementById("ph2").value = phone;
	window.opener.document.getElementById("paypoint").value = point;
  //window.opener.getElementById("hidecash").value = city;
	window.opener.document.getElementById("paycash").value = cash;
	window.close();
	window.opener.alert("\u6dfb\u52a0\u6210\u529f!!");
}
function mouseOver() {
	event.srcElement.className = "delMouseOver";
}
function mouseOut() {
	event.srcElement.className = "scheduleButtonVisible";
}
function mouseOver1() {
	window.opener.event.srcElement.className = "delMouseOver";
}
function mouseOut1() {
	window.opener.event.srcElement.className = "scheduleButtonVisible";
}

function delIt() {
	var pll = document.getElementById("PLList");
	line = parseInt(event.srcElement.ln, 10);
	if (line > 0) {
		for (i = 1; i < pll.rows.length; i++) {
			if (tdt[i].ln == line) {
				if (!confirm("\u786e\u5b9a\u5220\u9664\u5417?")) {
					return;
				}
				pll.deleteRow(i);
	//allCount--
			}
		}
	}
	reCash3();
}
function reCash(value) {
	document.orderForm.delivercash.value = value;
	reCash3();
}
function reCash2(v3) {
	var ss = document.getElementById("PLList");
    var rw = ss.rows[v3];
    var cc1 = rw.childNodes[7];
	var cc2 = rw.childNodes[6].childNodes[0];
	var cc3 = rw.childNodes[3].getElementsByTagName("input")[0];	
	cc1.innerHTML = cc2.value * cc3.value;
	reCash3();
}

function reCash3() {
	var ta = document.getElementById("PLList");
	var tal = 0;
    for(i=1;i<ta.rows.length;i++){
      tal = ta.rows[i].childNodes[7].innerHTML*1 + tal;
   }
	var c = window.orderForm.delivercash.value * 1;
	var p = window.orderForm.paypoint.value * 1;
	var pc = window.orderForm.paycash.value * 1;
	//window.orderForm.allcash.value = tal + c - p - pc;
}
function delAll() {
	var pll = document.getElementById("PLList");
	if (pll.rows.length > 1) {
		if (!confirm("\u786e\u5b9a\u5168\u90e8\u5220\u9664\u5417?")) {
			return;
		}
		for (i = pll.rows.length; i > 1; i--) {
			pll.deleteRow(i - 1);
		}
	//allCount--
	}
	reCash3();
	tableFont("12px");
}
function tableFont(aa) {
	var ss = document.getElementsByTagName("table");
	for (i = 0; i < ss.length; i++) {
		ss[i].style.fontSize = aa;
	}
}
function newOpenerHistory(a, b, c, d) {
	
	 window.opener.document.getElementById("orderindexConsignee").value = a; 
	 window.opener.document.getElementById("orderindexAddress").value = b; 
	 window.opener.document.getElementById("orderindexPostcode").value = c;
	 window.opener.document.getElementById("orderindexMobilephone").value = d;
	 
} 
 
function newOpenerHistoryInsert(a, b, c, d) {   
	 
	$.ajax({
		  type: "POST",
		  url: "addBillManage.do?method=saveHistory",
		  data: "a="+a+"&b="+b+"&c="+c+"&d="+d,
			 success: function(msg){
				 
			 }
		}); 
	  
	newOpenerHistory(a, b, c, d);
}
 
function reCash21(a){
   var ss = "idi" + a;
   var s1 = window.document.getElementById(ss);
   var trt = s1.parentNode.parentNode;
   var va = trt.childNodes[4].childNodes[2];
   var va5 = trt.childNodes[4].childNodes[1];
   var va1 = trt.childNodes[4].childNodes[0];
   var va2 = trt.childNodes[3].childNodes[0];
   var va3 = trt.childNodes[6].childNodes[0];
   var va4 = trt.childNodes[7];
   if(va.value==0){
   va2.value = va1.value;
   va4.innerHTML = va2.value * va3.value;
   }else{
   va2.value = va5.value;
   va4.innerHTML = va2.value * va3.value;
   }
   reCash3();
   tableFont("12px");
}

function newOpenerHospitalVisit(a, b, c, invoice,isorno,v1,v2,v3,v4,v5,v7,v8) {
    var shu = v1 + "," + v2 + "," + v3 + "," + v4 + "," + v5 + "," + v7 + "," + v8;
	var ss = window.opener.document.getElementById("PLList");
    allCount = ss.rows.length;
	for (i = 1; i <= allCount; i++) {
		var cc = eval("window.opener.orderForm.deid" + i);
		if (cc == null) {
			continue;
		}
		if (c == cc.value) {
			alert("此记录已经存在!");
			return;
		}
	}
	
	var pll = window.opener.document.getElementById("PLList");
	newRow = pll.insertRow(pll.rows.length);
	newRow.id = "tdt";
	newRow.ln = allCount;
	newRow.bgColor = "#e0e0e0";
	newRow.className = "tableData";
	c1 = newRow.insertCell(0);
	c1.id = "delItem";
	c1.ln = allCount;
	c1.className = "scheduleButtonVisible";
	c1.onclick = opener.delIt;
	c1.onmouseover = opener.mouseOver;
	c1.onmouseout = opener.mouseOut;
	c1.innerHTML = "<input type=hidden name=deid" + allCount + " value=" + c + "><input type=hidden name=billson value=''><input type=hidden name=shushu value="+ shu +">";
	c2 = newRow.insertCell(1);
	c2.ln = allCount;
	c2.className = "td_06";
	c2.innerHTML = b;
	c3 = newRow.insertCell(2);
	c3.ln = allCount;
	c3.innerHTML = "<input type=text  name=comm" + allCount + " ln=" + allCount + " />";
	c3.className = "td_06";
	c4 = newRow.insertCell(3);
	c4.ln = allCount;
	c4.innerHTML = "<input type=text size=10 value=" + a + " maxlength=100 name=price" + allCount + " ln=" + allCount + " class=tableData onBlur='reCash2(" + allCount + ")' >";
	c4.className = "td_06";
	c5 = newRow.insertCell(4);
	c5.ln = allCount;
	c5.innerHTML = "<input type='hidden' value="+ a +" id = idi" + allCount + "><input type='hidden' value="+ invoice +"><select size=1 maxlength=100 name=isNeedInvoice" + allCount + " ln=" + allCount + " class=tableData onchange='reCash21(" + allCount + ")'><option value=0>否</option><option value=1>是</option></select>";		
	c5.className = "td_06";
	c6 = newRow.insertCell(5);
	c6.ln = allCount;
	c6.innerHTML = isorno;
	c6.className = "td_06";
	c7 = newRow.insertCell(6);
	c7.ln = allCount;
	c7.innerHTML = "<input type=text size=10 maxlength=100 name=count" + allCount + " ln=" + allCount + " class=tableData onBlur='reCash2(" + allCount + ")' value=1>";
	c7.className = "td_06";
	c8 = newRow.insertCell(7);
	c8.ln = allCount;
	c8.innerHTML = a*1;
	c8.className = "td_06";
	allCount++;
	var ta = window.opener.document.getElementById("PLList");
	var tal = 0;
   for(i=1;i<ta.rows.length;i++){
     tal = ta.rows[i].childNodes[7].innerHTML*1 + tal;
  }    
	var c = window.opener.orderForm.delivercash.value * 1;
	var p = window.opener.orderForm.paypoint.value * 1;
	var pc = window.opener.orderForm.paycash.value * 1;
	//window.opener.orderForm.allcash.value = tal + c - p - pc;
	window.close();
}


  function theBigPropper(url,w,h){
  var l = (screen.availWidth - w) / 2; 
  var t = (screen.availHeight - h) / 2
  var s = 'width=' + w + ', height=' + h + ', top=' + t + ', left=' + l; 
  var src = s+",location=no,menubar=no,resizable=yes,status=no,toolbar=no";
  newWin=window.open(url,"theNewWindow",src);
  tableFont("12px");
}


 function theBigPropper3(url,w,h){
  var l = (screen.availWidth - w) / 2; 
  var t = (screen.availHeight - h) / 2
  var src = "scrollbars=yes,menubar=no,resizable=yes,status=no,toolbar=no";
  newWin=window.open(url,"theNewWindow",src);
  tableFont("12px");
}

  function theBigPropper2(url,w,h,a){
  var l = (screen.availWidth - w) / 2; 
  var t = (screen.availHeight - h) / 2
  var s = 'width=' + w + ', height=' + h + ', top=' + t + ', left=' + l; 
  var src = s+",location=no,menubar=no,resizable=yes,status=no,toolbar=no";
  newWin=window.open(url,"theNewWindow",src);
  baichi(a);
  tableFont("12px");
}

function baichi(a){
  var v1 = document.getElementById("wuliao");
  var v2 = document.getElementById("sb");
  var v3 = document.getElementById("wuliu2gao");
  if(a==1){
  v2.value = 1;
  if(v1.value==1){
  v3.disabled = false;
  }
  }
  if(a==0){
  v1.value = 1;
  if(v2.value==1){
  v3.disabled = false;
  }
  }
  }

function tiao(uri){
    if(uri==jsCtx+"/addBillManage.do?method=downloadExcel"){
    var form1=document.getElementById("for");
   var inputname = form1.getElementsByTagName("input");
   for(var i=0;i<inputname.length;i++){
   if(inputname[i].className!="Wdate"){
   inputname[i].focus();
   inputname[i].blur();
   }
   }
   var fan = form1.getElementsByTagName("span");
   var j = 0;
   var ss = "";
   for(var i=0;i<fan.length;i++){
     if(fan[i].innerHTML!=""){
     if(j==0){
     ss = fan[i];
     }
     j ++;
     }
   }
   if(j != 0){
   //alert("请检查输入项目!");
   ss.parentNode.getElementsByTagName("input")[0].focus();   
   }else{
   form1.action=uri;
	form1.submit();
	form1.action=jsCtx+"/addBillManage.do?method=resultList";
   } 
    }else if(uri==jsCtx+"/addBillManage.do?method=normalSelect"){
    var form1=document.getElementById("aa");
    var ss = document.getElementById("biao");
    ss.value = "you";
    form1.submit();
    ss.value = "";
    }else{
    var ss = window.location;
	ss.href = uri;
	tableFont("12px");
    } 
}
function tiaosubmit(uri){
 	if (!confirm("是否确认提交?")) {
					return false;
	  }
    var form1=document.getElementById("form1");
    form1.action=uri;
	form1.submit();
}

function yin(aa){
  var s = document.getElementById(aa);
  if(s.style.display=='block'){
   s.style.display = 'none';
  }else{
   s.style.display = 'block';
   tableFont("12px");
  }
} 
function xuan(s){
    var aa = document.getElementById("xuanze");
    var chang = document.getElementById("chang1");
    var chang1 = document.getElementById("chang2");
	var ww = aa.getElementsByTagName("select");
    for(var i=0;i<ww.length;i++){
	if(s.name!=ww[i].name){
	   ww[i].options[0].selected=true;
	}else{
	   if(ww[i].options[0].selected==true){
	     chang.disabled = true;
	     chang1.disabled = true;
	   }else{
	     chang.disabled = false;
	     chang1.disabled = false;
	   }
	}  
  }
}

function countload(){
 var ss = document.getElementById("buzhi");
   var a = document.getElementById("gaousepoint");
   var b = document.getElementById("gaousebalance");
   var c = document.getElementById("gaoneedcarriage");
  // var d = document.getElementById("gaotaltole");
   var total = 0;
   var se = ss.rows.length - 4;
   for(var i=2;i<se;i++){
      var s1 = ss.rows[i].childNodes[2].innerHTML;
      var s2 = ss.rows[i].childNodes[3].innerHTML;
      ss.rows[i].childNodes[6].innerHTML = s1*s2;
    total = total + ss.rows[i].childNodes[6].innerHTML*1;
   }
   d.innerHTML = total * 1  + c.innerHTML *1 - a.innerHTML *1 - b.innerHTML *1;
    tableFont("12px");
}
function countAll(aa){
	
   var ss = document.getElementById("buzhi");
   var a = document.getElementById("gaousepoint");
   var b = document.getElementById("gaousebalance");
   var c = document.getElementById("gaoneedcarriage");
   //var d = document.getElementById("gaotaltole");
   var kefugao = document.getElementById("kefugao");
   var wuliugao = document.getElementById("wuliugao");
   var wuliu2gao = document.getElementById("wuliu2gao");
   var caiwugao = document.getElementById("caiwugao");
   if(aa==1){
        caiwugao.disabled = true;
        wuliugao.disabled = true;
        wuliu2gao.disabled = true;
   }else if(aa==2){
        wuliugao.disabled = true;
        kefugao.disabled = true;
        wuliu2gao.disabled = true;
   }else if(aa==3){
        kefugao.disabled = true;
        caiwugao.disabled = true;  
        wuliu2gao.disabled = true; 
   }else if(aa==4){
   		wuliugao.disabled = true; 
		kefugao.disabled = true;
        caiwugao.disabled = true;  
   }
   var total = 0;
   var se = ss.rows.length - 5;
   for(var i=2;i<se;i++){
      var s1 = ss.rows[i].childNodes[2].innerHTML;
      var s2 = ss.rows[i].childNodes[3].innerHTML;
      ss.rows[i].childNodes[6].innerHTML = s1*s2;
    total = total + ss.rows[i].childNodes[6].innerHTML*1;
   }
   //d.innerHTML = total * 1  + c.innerHTML *1 - a.innerHTML *1 - b.innerHTML *1;
    tableFont("12px");
}
function countmoney(){
   var ss = document.getElementById("buzhi");
   var a = document.getElementById("gaousepoint");
   var b = document.getElementById("gaousebalance");
   var c = document.getElementById("gaoneedcarriage");
   //var d = document.getElementById("gaotaltole");
   var total = 0;
   var se = ss.rows.length - 4;
   for(var i=2;i<se;i++){
      var s1 = ss.rows[i].childNodes[2].innerHTML;
      var s2 = ss.rows[i].childNodes[3].innerHTML;
      ss.rows[i].childNodes[6].innerHTML = s1*s2;
    total = total + ss.rows[i].childNodes[6].innerHTML*1;
   }
   d.innerHTML = total * 1  + c.innerHTML *1 - a.innerHTML *1 - b.innerHTML *1;
    tableFont("12px");
}
function forward(id,index,method,customerid,wuliu,caiwu,wuliu2,dianzi){
   var uri =jsCtx+"/addBillManage.do?method="+method+"&id="+id+"&billstatus=" + encodeURI(eval("billstatus" + index).innerHTML)+"&customerid="+customerid+"&wuliu="+wuliu+"&caiwu="+caiwu+"&wuliu2="+wuliu2+"&dianzi="+dianzi;
   window.open(uri,'mainFrame');
}
function dianzifw(id,index,method,customerid,wuliu,caiwu,wuliu2,dianzi){
   var uri =jsCtx+"/addBillManage.do?method="+method+"&id="+id+"&billstatus=" + 
   encodeURI(eval("billstatus" + index).innerHTML)+"&customerid="+customerid+"&wuliu="+wuliu+"&caiwu="+caiwu+"&wuliu2="+wuliu2+"&dianzi="+dianzi;
   window.open(uri,'mainFrame');
}

function countAll2(){
   var ss = document.getElementById("buzhi");
   var a = document.getElementById("gaousepoint");
   var b = document.getElementById("gaousebalance");
   var c = document.getElementById("gaoneedcarriage");
   var d = document.getElementById("gaotaltole");
   var sumCount=document.getElementById("sumCount");
   var sCount=0;
   var total = 0;
   var se = ss.rows.length - 5;
   for(var i=1;i<se;i++){
      var s1 = new Number(ss.rows[i].cells[2].innerHTML);
      sCount+=s1;
      var s2 = new Number(ss.rows[i].cells[3].innerHTML);
      ss.rows[i].cells[6].innerHTML = s1*s2;
    total = total + ss.rows[i].cells[6].innerHTML*1;
   }
   sumCount.innerHTML=sCount;
   d.innerHTML = total * 1  + c.innerHTML *1 - a.innerHTML *1 - b.innerHTML *1;
    tableFont("12px");
}
function countAllss(){
   var ss = document.getElementById("buzhi");
   var a = document.getElementById("gaousepoint");
   var b = document.getElementById("gaousebalance");
   var c = document.getElementById("gaoneedcarriage");
   var d = document.getElementById("gaotaltole");
   var sumCount=document.getElementById("sumCount");
   var sCount=0;
   var total = 0;
   var se = ss.rows.length - 5;
   for(var i=1;i<se;i++){
      var s1 = new Number(ss.rows[i].cells[2].innerHTML);
      sCount+=s1;
      var s2 = new Number(ss.rows[i].cells[3].innerHTML);
      ss.rows[i].cells[5].innerHTML = s1*s2;
    total = total + ss.rows[i].cells[5].innerHTML*1;
   }
   sumCount.innerHTML=sCount;
   d.innerHTML = total * 1  + c.innerHTML *1 - a.innerHTML *1 - b.innerHTML *1;
    tableFont("12px");
}
function countAll3(){
   var ss = document.getElementById("buzhi");
   var se = ss.rows.length - 1;
   for(var i=2;i<se;i++){
      var s1 = new Number(ss.rows[i].cells[3].innerHTML);
      var s2 = new Number(ss.rows[i].cells[4].innerHTML);
      ss.rows[i].cells[7].innerHTML = s1*s2;
   }
}

function test(){
	var checkboxes=document.getElementsByName("checkbox");
	var ids="";
	for(i = 0; i < checkboxes.length; i++){	
		if(checkboxes[i].checked==true){
			if(ids==""){
				ids+=checkboxes[i].value;
			}else{
			ids+=','+checkboxes[i].value;
			}
		}
	}
	if(ids==""){
	   alert("没有选中的产品!");
	   return;
	}
	var id=document.getElementById("orderdetail.id").value;
	document.getElementById("ids").value=ids;
	document.getElementById("id").value=id;
	showFan.submit();
}

function orderSubmit(){
     
      if (!confirm("是否确认提交?")) {
					return false;
	  }
      window.close();
	  window.opener.location.reload();
	  return true;
}

function auto(){
      if(document.getElementById("isauto").value != ""){
      		var dianziId = document.getElementById("dianziId").value;
      		var obj = document.getElementById("dianziSeId");
      		 
			for(i=0;i<obj.length;i++){
			   if(obj[i].value == dianziId){
			      obj[i].selected = true;
			   }
			} 
			var caiwuId = document.getElementById("caiwuId").value;
      		var obj = document.getElementById("caiwuSeId");
      		for(i=0;i<obj.length;i++){
			   if(obj[i].value == caiwuId){
			      obj[i].selected = true;
			   }
			} 
			
			var wuliuId = document.getElementById("wuliuId").value;
      		var obj = document.getElementById("wuliuSeId");
      		for(i=0;i<obj.length;i++){
			   if(obj[i].value == wuliuId){
			      obj[i].selected = true;
			   }
			} 
			
			var wuliu2Id = document.getElementById("wuliu2Id").value;
      		var obj = document.getElementById("wuliu2SeId");
      		
      		for(i=0;i<obj.length;i++){
			   if(obj[i].value == wuliu2Id){
			      obj[i].selected = true;
			   }
			} 
      		document.getElementById("aa").submit();
      }
}

function check() {
  if (document.productsons.name.value=="") {
    alert("请输入顾客姓名！");
    document.productsons.name.focus();
    return (false);
  }else if (document.productsons.phone.value=="") {
    alert("请输入联系电话！");
    document.productsons.phone.focus();
    return (false);
  }else if (document.productsons.product.value=="") {
    alert("请选择预定的产品！");
    return (false);
  }else if (document.productsons.role.value=="") {
    alert("请选择职业！");
    return (false);
  }
  return true;
}
function getCity(){
   var product_id = document.getElementsByName('myorderproduct.product_id')[0].value;          
   var ss = /^[1-9]\d*$/;
   if(product_id==""||(!ss.test(product_id))){
   document.getElementById("xx").innerHTML = "请输入正确的商品ID!";
   }else{
   var url= jsCtx+"/productSon.do";
   new Ajax.Request(url,{
				method : "post",
				parameters : "method=addProduct1&myorderproduct.product_id="+product_id,
				onComplete : function(xhr){
				var chenchen = xhr.responseText;
	if(parseInt(chenchen)==1){
	     var fo = document.getElementById("xxx");
	     fo.action = jsCtx+"/productSon.do?method=addProduct"; 
		 fo.submit();
		 fo.action = "";
	}else if(parseInt(chenchen)==0){
		document.getElementById("xx").innerHTML="此商品ID不存在";
	}else{
	document.getElementById("xx").innerHTML="已存在";
	} 
	}  
	});
	}
} 
